package generators;

import gamebackend.Block;

public class PipeGenerator extends AbstractGenerator implements BlockGenerator {

	private Block my_path;
	public PipeGenerator(final Block the_path, final Block the_block) {
		super(the_block);
		my_path = the_path;
	}
	@Override
	public void generate(Block[][] blocks) {
		for (int col = 0; col < blocks[1].length; col++) {
			if (blocks[1][col] == my_path) {
				for (int x = -1; x < 2; x++) {
					for (int y = 0; y < 3; y++) {
						placeBlock(blocks, y, x + col);
					}
				}
			}
			
			
		}

	}
	private void placeBlock(Block[][] blocks, int row, int col) {
		if (row >= 0 && row < blocks.length && col >= 0
				&& col < blocks[0].length && blocks[row][col] == Block.EMPTY_BLOCK) {
			blocks[row][col] = getBlock();
		}
	}

}
